<script type="text/javascript" src="<?= APPLICATION_SITEADMIN_URL ?>fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="<?= APPLICATION_SITEADMIN_URL ?>fckeditor/ewp.js"></script>
<script type="text/javascript">

    _width_multiplier = 16;
    _height_multiplier = 30;
    var EW_DHTMLEditors = [];
    function EW_UpdateTextArea() {
    if (typeof EW_DHTMLEditors != 'undefined') {
    if (FCKeditorAPI) {
    var inst;			
    for (inst in FCKeditorAPI.__Instances)
    FCKeditorAPI.__Instances[inst].UpdateLinkedField();
    }
    }
    }


</script>
<?
$id = 0;
$table = "media_item";
$mod = $_GET['mod'];
$title_add = 'Add "Media Item"';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $db = new MySQL();
    $sql = $db->select("select * from $table where id='$id'");
    if ($db->numrows($sql) > 0)
        $te = $db->fetch($sql);
    $db->close();
    $title_add = 'Edit "Media Item"';
}
?>
<script type="text/JavaScript">
    function checkinput()
    {
    return true;
    }

    function save(id)
    {
    var frm=document.frmedit;		
    if(checkinput())
    {
    if(id==0)  frm.action="?mod=<?= $mod ?>&act=process";
    else frm.action="?mod=<?= $mod ?>&act=process&id="+id;
    frm.method="POST";
    frm.submit();
    }
    }

    function resetfrom()
    {
    document.frmedit.reset();

    }
</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="34"><img src="<?= APPLICATION_SITEADMIN_URL ?>images/cor_data_top_l.gif" alt="tl" width="34" height="19" /></td>
                    <td class="toptborder">&nbsp;</td>
                    <td width="20"><img src="<?= APPLICATION_SITEADMIN_URL ?>images/cor_data_top_r.gif" alt="tr" /></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="10" class="leftborder">&nbsp;</td>
                    <td><table width="100%" border="0" cellpadding="0" cellspacing="2" class="dataBack">
                            <tr>
                                <td width="55%" height="36" class="titleOrange"><?= $title_add ?></td>
                                <td align="right" valign="middle" class="titleOrange">&nbsp;</td>
                            </tr>
                            <tr>
                                <td height="7" colspan="2" background="images/cor_data_line1.gif"></td>
                            </tr>
                            <tr>
                            <form name="frmedit" method="post" enctype="multipart/form-data" >
                                <td  colspan="2" ><table width="100%" border="0" cellspacing="0">
                                        <!--
                                        <tr>
                                          <td width="19%" align="right" valign="top">Category: </td>
                                          <td >
                                              <select name="cbidcat">
                                              <option value="0"></option>
                                        <?
                                        $db = new MySQL();
                                        $qr_cat = "select * from media_cat order by orderId";
                                        $re_cat = $db->select($qr_cat);
                                        while ($tt_cat = $db->fetch($re_cat)) {
                                            echo '<option value="' . $tt_cat['id'] . '" ';
                                            if ($te['idcat'] == $tt_cat['id'])
                                                echo " selected";
                                            elseif ($_GET['idcat'] == $tt_cat['id'])
                                                echo " selected";
                                            echo ' >' . $tt_cat["title"] . '</option>';
                                        }
                                        $db->close();
                                        ?>									
                                              </select>
                                              </td>
                                        </tr>
                                        -->
                                        <tr>
                                            <td width="19%" align="right" valign="top">Title : </td>
                                            <td ><input name="title" type="text" class="form_0" value="<?= $te['title'] ?>" ></td>
                                        </tr>
                                        <tr>
                                            <td align="right" valign="top">Title (Vietnamese) : </td>
                                            <td ><input name="title_vn" type="text" class="form_0" value="<?= $te['title_vn'] ?>" ></td>
                                        </tr>
                                        <!--
                                        <tr>
                                            <td align="right" valign="top">Feature Image (300px*300px) : </td>
                                            <td ><input type="file" name="image" />
                                                <?php
                                                if ($te['image'] != "" && file_exists("../product-img/list/" . $te['image'])) {
                                                    echo '<br/><img src="../product-img/list/' . $te['image'] . '"  />';
                                                }
                                                ?></td>
                                        </tr>
                                        -->

                                        <tr>
                                            <td align="right" valign="top">Youtube Link : </td>
                                            <td ><input name="linkto" type="text" class="form_0" value="<?= $te['linkto'] ?>" ></td>
                                        </tr>	




                                        <!--	
                                        <tr>
                                          <td align="right" valign="top">Content: </td>
                                          <td align="left" valign="middle">
                                              <SPAN class=hideTrigger><span id="aaa" onClick="changeColor('aaa')">English</span></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;
                                              <SPAN class=hideTrigger><span id="bbb" onClick="changeColor('bbb')">Vietnamese</span></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;
                                              
                                                      <DIV  class=hideBlock id="aaa_s">
                                                      <P>
                                                      <textarea name="content" class="form_2"><?= $te['content'] ?></textarea>
                                                      <script type="text/javascript">
                                                              var editor = new EW_DHTMLEditor("content");
                                                              editor.create = function() {
                                                                      var sBasePath = '<?= APPLICATION_SITEADMIN_URL ?>fckeditor/';
                                                                      var oFCKeditor = new FCKeditor('content', 40*_width_multiplier, 10*_height_multiplier);
                                                                      oFCKeditor.BasePath = sBasePath;
                                                                      oFCKeditor.ReplaceTextarea();
                                                                      this.active = true;
                                                              }
                                                              EW_DHTMLEditors[EW_DHTMLEditors.length] = editor;
                                                      </script>		
                                                      </P></DIV>
                                              
                                              
                                              <DIV  class=hideBlock id="bbb_s">
                                                      <P>
                                              <textarea name="content_vn" class="form_2"><?= $te['content_vn'] ?></textarea>
                                              <script type="text/javascript">
                                                      var editor = new EW_DHTMLEditor("content_vn");
                                                      editor.create = function() {
                                                              var sBasePath = '<?= APPLICATION_SITEADMIN_URL ?>fckeditor/';
                                                              var oFCKeditor = new FCKeditor('content_vn', 40*_width_multiplier, 10*_height_multiplier);
                                                              oFCKeditor.BasePath = sBasePath;
                                                              oFCKeditor.ReplaceTextarea();
                                                              this.active = true;
                                                      }
                                                      EW_DHTMLEditors[EW_DHTMLEditors.length] = editor;
                                              </script>					
                                              </P>
                                              </DIV>					
                                              
                                                                              
                                              <script type="text/javascript">
                                              changeColor('aaa');
                                              </script>				</td>
                                        </tr>
                                        
                                        <!--
                                        <tr>
                                          <td align="right" valign="top">Keywords : </td>
                                          <td align="left" valign="middle">
                                              <textarea name="meta_key" class="form_3" ><?= $te['meta_key'] ?></textarea>					</td>
                                        </tr> 
                                         <tr>
                                          <td align="right" valign="top">Description : </td>
                                          <td align="left" valign="middle">
                                              <textarea name="meta_des" class="form_3"><?= $te['meta_des'] ?></textarea>					</td>
                                        </tr> 
                                        -->

                                        <tr>
                                            <td height="35" align="right" valign="top">&nbsp;</td>
                                            <td align="left" valign="middle">
                                                <img src="images/icons/save.png" onClick="save(<?= $id ?>);" class="pointer" />  &nbsp;
                                                <img src="images/icons/reset.png" onClick="resetfrom();" class="pointer" /> </td>
                                        </tr>
                                    </table>
                                    <input type="hidden" name="form_" value="edit">
                                </td>
                            </form>
                </tr>
            </table>
        </td>
        <td width="10" class="rightborder">&nbsp;</td>
    </tr>
</table></td>
</tr>
<tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="dataBack">
            <tr>
                <td width="34"><img src="<?= APPLICATION_SITEADMIN_URL ?>images/cor_data_bot_l.gif" alt="bl" /></td>
                <td class="botborder" >&nbsp;</td>
                <td width="19"><img src="<?= APPLICATION_SITEADMIN_URL ?>images/cor_data_bot_r.gif" alt="br" /></td>
            </tr>
        </table></td>
</tr>
</table>

<script type="text/javascript">
    <!--
    EW_createEditor();  // Create DHTML editor(s)

    //-->
</script>